﻿

CREATE FUNCTION [dbo].[GetFinalNumberAntet]
(
	@Numar varchar(50)
)
RETURNS varchar(50)
AS
BEGIN
	-- Declare the return variable here
	DECLARE @ResultVar varchar(50)
	SET @ResultVar = ''
	DECLARE @i int
	SET @i=LEN(@Numar)
	WHILE @i > 0
	BEGIN 
		if SUBSTRING(@numar,@i,1) <= '9' AND SUBSTRING(@numar,@i,1) >= '0'
			SET @i = @i - 1
		else
			break
	END 
	IF @i > 0
		SET @ResultVar = SUBSTRING(@numar,1,@i)
	
	-- Return the result of the function
	RETURN @ResultVar

END